package com.ebupt.migu.music.schedule.controller;


import com.ebupt.migu.music.schedule.service.PubBroadcastingActTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 公播平台活动加载定时器
 */
@Slf4j
@Component
@EnableScheduling
public class PubBroadcastingActTask {

    @Autowired
    private PubBroadcastingActTaskService pubBroadcastingActTaskService;

    /**
     * 启动公播平台活动
     * #每2分钟运行一次0 0/2 * * * ?
     */
    @Scheduled(cron = "${cron.startActivity}")
    public void startActivity() {
        log.info("启动公播平台活动---开始");
        pubBroadcastingActTaskService.startActivity();
        log.info("启动公播平台活动---结束");
    }

    /**
     * 停止公播平台活动
     * #每天0点到1点 没1分钟运行一次0 0/1 0-1 * * ?
     */
    @Scheduled(cron = "${cron.stopActivity}")
    public void stopActivity() {
        log.info("停止公播平台活动---开始");
        pubBroadcastingActTaskService.stopActivity();
        log.info("停止公播平台活动---结束");
    }

}
